using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class grenade : MonoBehaviour
{
    Rigidbody2D rigid;
    public float speed;

    public Transform boomAnim; 
    // Start is called before the first frame update
    void Start()
    {
        transform.SetParent(null);
        transform.right = GameObject.Find("Player").transform.localScale.x *transform.right;
        
        rigid = GetComponent<Rigidbody2D>();
        rigid.velocity = (transform.right + transform.up) * speed; 
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        Instantiate(boomAnim, transform.position, Quaternion.identity);
        Destroy(gameObject);
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        Instantiate(boomAnim, transform.position, Quaternion.identity);
        Destroy(gameObject);
    }
}
